import time
from zhipuai import ZhipuAI
client = ZhipuAI(api_key="a31cc1500ce8aa88e1778e57cb431c81.wbIvrk5PGWD5IJjI")
with open("batchid.txt","r",encoding="utf-8") as f:
      for line in f:
            if line !="":
                  batch_id=line.strip()
      print(batch_id) #write in the id u wanted with 'batch_id="ur_id_in batchid.txt"' other wise will use the newest one in default       
      batch_job = client.batches.retrieve(batch_id=batch_id)
      print(batch_job.status)
      output_file_id=batch_job.output_file_id
      print(output_file_id)
      if batch_job.status=="completed":
            content = client.files.content(output_file_id) 
            content.write_to_file("output.jsonl")
            print("this task done successfully")
      elif batch_job.status in ["validating","in_progress","finalizing"]:
            print("hang on, file is processing")
      else:
            print("this task is failed")

            
  
